import request from '@/utils/request'

// 查询项目管理列表
export function listUser(data) {
  return request({
    url: '/project/list',
    method: 'post',
     data: data
  })
}
// 查询项目详细信息
export function getProject(project_id) {
  return request({
      url: '/project/findById',
      method: 'get',
      params: { project_id }
  })

}
//删除成员
export function deleteMember(project_id, user_id) {
  return request({
      url: '/project/deleteMember',
      method: 'delete',
      params: { project_id, user_id }
  })
  }

  //添加成员
  export function addMember(project_id, user_id ) {
    return request({
        url: '/project/addMember',
        method: 'put',
        params: { project_id, user_id },
    })
  }
  //停止项目
  export function updateProjectStatus(project_id,status) {
    return request({
        url: '/project/updateProjectStatus',
        method: 'put',
        params: { project_id, status },
    })
  }
//删除项目
export function deleteProject(project_id,user_id,pass_word) {
  return request({
      url: '/project/deleteProject',
      method: 'delete',
      params: { project_id,user_id,pass_word },
  }
  )
}

//修改项目信息
export function updateProject(data) {
  return request({
      url: '/project/updateProject',
      method: 'post',
      data: data
  })
}

//上传项目文件
export const uploadProjectFile  = (formData) => {
    return request({
        url: '/uploadProjectImg',
        method: 'post',
        data: formData
    })
}
//删除项目文件
export const deleteProjectFile  = (url) => {
    return request({
        url: '/deleteProjectImg',
        method: 'delete',
        params: { url }
    })
}
//添加项目
export function addProject(data) {
  return request({
      url: '/project/addProject',
      method: 'post',
      data: data
  })
    }
//添加项目的上传文件

export const uploadAddProjectFile  = (formData) => {
    return request({
        url: '/uploadAddProjectImg',
        method: 'post',
        data: formData
    })
}

//导出
export function exportProject(user_name) {
    return request({
        url: '/project/exportExcel',
        method: 'get',
        params: { user_name },
        responseType: 'blob'
    });
}

//学生加入项目
export function joinProject(project_id, user_id) {
  return request({
      url: '/project/joinProject',
      method: 'put',
      params: { project_id, user_id },
  })
}

//查询审申请加入项目列表
export function listJoinProject() {
  return request({
    url: '/project/listJoinProject',
    method: 'get'
  })
}
//同意审批加入项目
export function agreeJoinProject(project_id, user_id) {
  return request({
      url: '/project/agreeJoinProject',
      method: 'put',
      params: { project_id, user_id },
  })
}
//拒绝审批加入项目
export function refuseJoinProject(data) {
  return request({
      url: '/project/refuseJoinProject',
      method: 'post',
      data: data
   })
}

//查询我申请加入的项目(待审批)、(已同意)、(已驳回)
export function listMyJoinProject( user_id,status) {
    return request({
        url: '/project/listMyJoinProject',
        method: 'get',
        params: { user_id,status }
    })

}

//自己取消申请加入项目
export function cancelJoinProject(project_id, user_id) {
  return request({
      url: '/project/cancelApply',
      method: 'delete',
      params: { project_id, user_id },
  })
}
//查询我的项目列表
export function listMyProject(user_id,status,type) {
    return request({
        url: '/project/listMyProject',
        method: 'get',
        params: { user_id,status,type }
    })
}
//取消申请创建项目
export function cancelCreateProject(project_id) {
  return request({
      url: '/project/cancelCreateProject',
      method: 'delete',
      params: { project_id },
  })
  }

//管理查看需要审核的项目列表
export function listNeedCheckProject() {
    return request({
        url: '/project/listNeedCheckProject',
        method: 'get'
    })
}

//同意项目申请或者拒绝项目申请
export function  checkProject(data)
{
    return request({
        url: '/project/checkProject',
        method: 'post',
        data: data
    })
}

//统计
export function getStatistics() {
    return request({
        url: '/project/statistics',
        method: 'get'
    })
}